import request from "@/utils/request";

let apiUrl = import.meta.env.VITE_APP_ENV === "development" ? "/smart-api/" : window.scjConfig.smartApi;
// let apiUrl = 'https://www.scjgj.sh.cegn.cn/query/knowledge/query/';

const resDataFn = (promise) => {
  return new Promise((resolve, reject) => {
    promise
      .then((d) => {
        if (d.code === "0" && d.data !== undefined) {
          resolve(d.data);
        } else if (typeof d == "object") {
          resolve(d);
        } else {
          reject(d.message);
        }
      })
      .catch((err) => {
        reject(err);
      });
  });
};
/**
 * 查询数据
 * @param {string} query 查询字符串
 */
export function getRecord(query) {
  return resDataFn(
    request({
      url: `${apiUrl}api/graph/query/record`,
      method: "post",
      data: {
        data: {
          query,
        },
        rid: "string",
      },
    })
  );
}

// https://441537m8i0.imdo.co
// http://172.18.6.13:9088
//测试
//let baseUrl = 'http://172.18.6.13:9088';
let baseUrl = import.meta.env.VITE_APP_ENV === "development" ? "https://10.86.138.22/kgapi2" : window.scjConfig.baseUrl;
let baseUrl2 = "http://124.70.187.7"
// if (import.meta.env.VITE_APP_ENV === "development") {
//   baseUrl = 'http://172.18.6.13:9088';
//   baseUrl2 = "http://124.70.187.7"
// } else {
//   //baseUrl = "https://10.86.138.22/kgapi2"
//   //baseUrl2 = "https://10.86.138.22/nlpapi"
//   baseUrl = 'http://172.18.6.13:9088';
//   baseUrl2 = "http://124.70.187.7"
// }

//const baseUrl = 'http://172.31.52.12:9088';
//生产
//let baseUrl = " https://10.86.138.22/kgapi2"
//let baseUrl2 = "https://10.86.138.22"
/** 1. 违法行为识别 */
export function getAssisttantAct(filter) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/act`,
    method: "post",
    data: {
      data: {
        caseFilter: filter,
      },
      rid: ''
    }
  }));
}
/** 1. 违法行为识别新 */
export function getActFilter(filter) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/act/filter`,
    method: "post",
    data: {
      data: {
        caseFilter: filter,
      },
      rid: ''
    }
  }));
}

/** 3. 类案检索 */
export function getAssisttantCase(filterData) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/case`,
    method: "post",
    data: {
      data: {
        caseData: {
        },
        caseFilter: filterData,
        clueNo: ''
      },
      rid: ''
    }
  }));
}

/** 字典 */
export function assisttantDic(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/dic`,
    method: "post",
    data: {
      data: data,
      rid: ''
    }
  }));
}

/** 文本数据识别 */
export function assisttantParse(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/parse`,
    method: "post",
    data: {
      data: data,
      rid: ''
    }
  }));
}
/** 内容类别识别 */
export function nlpCls(data) {
  return resDataFn(request({
    url: `${baseUrl2}/nlp/cls`,
    method: "post",
    data
  }));
}
/** 内容类别最新智能接口 */
export function nlpExtract(data) {
  return resDataFn(request({
    url: `${baseUrl2}/nlp/extract`,
    method: "post",
    data
  }));
}
/** 内容类别抽取 */
export function nlpUieUiePrductBrand(data) {
  return resDataFn(request({
    url: `${baseUrl2}/nlp/uie/uie_prduct_brand`,
    method: "post",
    data
  }));
}

/** 智能辅助 */
export function assisttantPunish() {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/punish`,
    method: "post",
    data: {
      data: {
        caseData: {
        },
        caseFilter: {
        },
        clueNo: '',
        id: ''
      },
      rid: ''
    }
  }));
}

/** 点赞 */
export function assisttantThumbUp(isThumbUp, code) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/thumbup`,
    method: "post",
    data: {
      data: {
        reqJson: '',
        responseItemJson: '',
        responseJson: '',
        uid: ''
      },
      rid: ''
    }
  }));
}

/** 保存 */
export function filterSave(filterData, name) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/case/filter/save`,
    method: "post",
    data: {
      data: {
        filter: filterData,
        name: name
      }
    }
  }));
}

export function filterGet() {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/case/filter/get`,
    method: "post",
    data: {
      data: {
      }
    }
  }));
}
/** 常用检索条件删除*/
export function assisttantCaseFilterDel(id) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/case/filter/del`,
    method: "post",
    data: {
      data: { id },
      rid: '123'
    }
  }));
}
/** 智能辅助-获取裁量 */
export function discretionaryBenchmark(illigelActId) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/discretionary_benchmark`,
    method: "post",
    data: {
      data: {
        caseFilter: {
          illigelActId: illigelActId,
        }
      }
    }
  }));
}
/** 智能辅助-获取裁量2 */
export function assisttantPunishDesc(filterData) {
  return resDataFn(request({
    url: `${baseUrl}/api/ai/assisttant/punish_desc`,
    method: "post",
    data: {
      data: {
        caseData: {
        },
        caseFilter: filterData,
        clueNo: ''
      },
      rid: ''
    }
  }));
}
/** 首页 */
export function statsActions(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/stats/stats/actions`,
    method: "post",
    data: data,
  }));
}
/** 法律法规查询---列表 */
export function lawQueryLaw(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/law/query/law`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  }));
}
/** 法律法规查询---详情 */
export function lawLaw(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/law/law`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  }));
}
/** 裁量基准查询---列表 */
export function lawQueryStd(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/law/query/std`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  }));
}
/** 裁量基准明细---详情 */
export function lawStd(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/law/std`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  }));
}
/** 违法行为---列表 */
export function lawActQuery(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/law/act/query`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  }));
}
/** 违法行为明细---详情 */
export function lawAct(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/law/act`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  }));
}
/** 登录*/
export function login(data) {
  return resDataFn(request({
    url: `${baseUrl}/api/login/auth/login`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  }));
}
/** 收藏*/
export function collectCollect(data) {
  return request({
    url: `${baseUrl}/api/collect/collect/collect`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  });
}
/** 查询收藏*/
export function collectQuery(data) {
  return request({
    url: `${baseUrl}/api/collect/collect/query`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  });
}
/** 消息信息*/
export function chatMessage(data) {
  return request({
    url: `${baseUrl}/api/chat/chat/message`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  });
}
/** 开始会话*/
export function chatSession(data) {
  return request({
    url: `${baseUrl}/api/chat/chat/session`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  });
}
/** 收藏会话*/
export function chatSessionCollect(data) {
  return request({
    url: `${baseUrl}/api/chat/chat/session/collect`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  });
}
/** 收藏会话列表*/
export function chatSessionCollectList(data) {
  return request({
    url: `${baseUrl}/api/chat/chat/session/collect/list`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  });
}
/** 消息信息(会话)*/
export function chatSessionMessages(data) {
  return request({
    url: `${baseUrl}/api/chat/chat/session/messages`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  });
}
/** 收藏会话取消*/
export function chatSessionUncollect(data) {
  return request({
    url: `${baseUrl}/api/chat/chat/session/uncollect`,
    method: "post",
    data: {
      data,
      rid: ""
    },
  });
}